package chapter_5;

public class Cylinder {
    private double radius;
    private int  height;
    private double pi = 3.14;
    public void setRadius(double radius){
        if(radius < 0){
            System.out.println("数据不合法");
        }
        this.radius = radius;
    }
    public double getRadius(){
        return this.radius;
    }
    public void setHeight(int height){
        this.height = height;
    }
    public int getHeight(){
        return  this.height;
    }
    public double volume(){
        return  area() * height;
    }
    public double area(){
        return  pi * radius * radius;
    }
}
